import os
from twisted.python.util import println



# print("\033[6;3HHello")
# print("\033[8;9HHello2")
# print("\033[10;15HHello3")
FACESIDE=('FRONT', 'BACK', 'LEFT', 'RIGHT', 'UP', 'DOWN')
xOrig = 4
yOrig=4
xDelta = 15
yDelta = 4
DIREZIONEMOSSA = ('CLOCKWISE','COUNTERCLOCKWISE')
PRINTFACESPOS = {   'FRONT':(yOrig + yDelta, xOrig + xDelta),
                    'BACK':(yOrig + yDelta, xOrig+ 3 * xDelta),
                    'LEFT':(yOrig + yDelta, xOrig ),
                    'RIGHT':(yOrig + yDelta, xOrig + 2 * xDelta),
                    'UP':(yOrig, xOrig + xDelta),
                    'DOWN':(yOrig + 2 * yDelta, xOrig + xDelta)}
INITIALCOLORS = {'FRONT':'RED', 'BACK':'ORA', 'LEFT':'BLU', 'RIGHT':'GRE', 'UP':'YEL', 'DOWN':'WHI'}
class TulRubikFace():
    def __init__(self, side):
        self.face=[['']*3]*3
        self.side = side
        color = INITIALCOLORS[side]
        for i in range(3):
            for j in range(3):
                self.face[i][j]=color
    def printface(self):             
        (row, col) = PRINTFACESPOS[self.side]   
        for i in range(3):
            for j in range(3):
                r = row + i
                c = col + j*5
                printstring = "\033[" + str(r) + ";" + str(c) + "H" + str(self.face[i][j])            
                println(printstring)
    #def __hash__(self):# tulrubikfase deveessere hasable per essere inserita in un dict
    #    return
            
            

class TulRubik():
    def __init__(self):
        self.faces=dict()
        for faceside in FACESIDE:
            #self.faces[faceside] = TulRubikFace(faceside)
            self.faces.update({faceside: TulRubikFace(faceside)})        
    def printCube(self):     
        # print self.faces  
        os.system('clear') 
        for faceside in FACESIDE:
            self.faces[faceside].printface()
    def moveFront(self, direction):
        if direction == 'CLOCKWISE':
            temp=self.faces['UP']
            
            
# rub = TulRubikFace('FRONT')
# rub.printface()

cube = TulRubik()
cube.printCube()
                